package network.server;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class ChatServer {
	
	public static void main(String[] args) throws IOException {
		
		ServerSocket sSock = null;
		try {
			sSock = new ServerSocket(5000);
		} catch (IOException e) {
			System.out.println("서버 소켓 생성 실패! 서버를 종료합니다.");
			e.printStackTrace();
			System.exit(1);
		}
		
		while (true) {
			Socket sock = sSock.accept();	// 클라이언트와 연결된 Socket 객체
			System.out.println("클라이언트와 연결이 수립되었습니다. "
					+ sock.getInetAddress());
			
			ChatThread t = new ChatThread(sock);
			t.start();
		}
		
//		sSock.close();
	}
	
}
